<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

    <!-- 满足有些用户在手机端访问的需要 -->

    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="0">

    <title>用户管理</title>
    <!-- 线上环境 -->
    <link rel="stylesheet" href="/static/css/dist/component-min.css">
    <link rel="stylesheet" href="/static/plugins/jbox/jbox-min.css">

    <!--vue-->
    <script src="/static/vue/vue.js"></script>
    <!--element ui-->
    <script src="/static/element/index.js"></script>
    <link rel="stylesheet" href="/static/element/index.css">
    <style>
        .el-table__empty-block {
            height: 0;
        }
    </style>

</head>
<body class="cp-bodybox">
<div id="app">
    <#include "/common/header-fg.html" />

    <div class="container">
        <div class="inner clearfix">
            <#include "/common/left-menu-fg.html" />

            <div class="content-right">
                <h1 class="content-right-title">积分提现管理</h1>
                <el-card class="box-card">
                    <el-form :inline="true" ref="search" :model="search" label-width="80px">
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="客户搜索">
                                    <el-input v-model="search.customerName" placeholder="昵称/手机号"></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="状态">
                                    <el-select v-model="search.status" placeholder="请选择状态">
                                        <el-option
                                                v-for="item in stateList"
                                                :label="item.name"
                                                :value="item.value">
                                        </el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="提交时间">
                                    <el-date-picker
                                            v-model="search.applyTimeStart"
                                            type="date"
                                            placeholder="选择日期">
                                    </el-date-picker>&nbsp;至&nbsp;
                                    <el-date-picker
                                            v-model="search.applyTimeEnd"
                                            type="date"
                                            placeholder="选择日期">
                                    </el-date-picker>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <div style="float: right">
                                    <el-button type="primary" @click.native.prevent="getList">查询</el-button>
                                    <el-button type="primary" @click.native.prevent="clearSearch">清空查询条件</el-button>
                                </div>
                            </el-col>
                        </el-row>
                    </el-form>
                </el-card>
                <div class="clearfix" style="margin-top: 10px">
                    <el-button type="primary" style="float: left;" @click.native="exportPoint">导出</el-button>
                </div>
                <yiqi-examine ref="examineDialog" :examine-dialog="examineDialog" :readonly="readonly"
                              :checked-list="checkedList" :result="result" :desc="desc"
                              :type-id="typeId" :save-callback="saveCallback" :cancel-callback="cancelCallback"></yiqi-examine>
                <el-card class="box-card" style="margin-top: 10px">
                    <el-table
                            :data="cashList"
                            border
                            style="width: 100%">
                        <el-table-column
                                type="index"
                                label="序号"
                                width="80">
                        </el-table-column>
                        <el-table-column
                                prop="customerName"
                                label="昵称">
                        </el-table-column>
                        <el-table-column
                                prop="customerTel"
                                label="手机号">
                        </el-table-column>
                        <el-table-column
                                prop="point"
                                label="申请积分">
                        </el-table-column>
                        <el-table-column
                                prop="applyTime"
                                align="center"
                                :formatter="formatterTime"
                                label="申请时间"
                                width="130">
                        </el-table-column>
                        <el-table-column
                                prop="statusName"
                                label="状态">
                        </el-table-column>
                        </el-table-column>
                        <el-table-column
                                align="center"
                                label="操作"
                                inline-template>
                            <div style="margin-left: -10px" v-if="isPermission('point:fetchCheck', user.permissions)">
                                <el-button size="small" v-if="row.status === 0" type="primary" @click="show(row.id)">审核</el-button>
                            </div>
                        </el-table-column>
                    </el-table>
                    <el-pagination
                            @current-change="handleCurrentPageChange"
                            :current-page="currentPage"
                            :page-size="pageSize"
                            layout="total, prev, pager, next"
                            :total="totalCount"
                            style="margin-top: 10px;">
                    </el-pagination>
                </el-card>
            </div>
            <!-- end content-right -->

            <a href="javascript:;" class="btn-leftMenuFold" id="j-btn-leftMenuFold"></a>
        </div>
    </div>
    <!-- end container -->

    <!--gonggao-->

    <!--tip-->
    <div class="footer">© 2017 , Inc. All rights reserved.</div>
    <!-- end footer -->
    <div class="fixedBar" style="right: -78px;">
        <ul>
            <template v-for="(item, index) in leftMenuList">
                <li v-if="index==0" :class="'shopManager' + index + ' cur'"><a href="javascript:;" :data-target="'#shop_' + index">{{item.groupName}}</a></li>
                <li v-else :class="'shopManager' + index"><a href="javascript:;" :data-target="'#shop_' + index">{{item.groupName}}</a></li>
            </template>
        </ul>
        <a href="javascript:;" class="fixedBar-btn" id="j-fixedBar-btn"></a>
    </div>
    <a href="#" id="j-gotop" class="gotop" title="回到顶部" style="left: 1920.59px;"></a>

</div>
<script src="/static/js/dist/lib-min.js"></script>
<script src="/static/js/dist/list.js"></script>
<script src="/static/js/dist/component-min.js"></script>
<script src="/static/js/common.js"></script>

<!-- 引入api -->
<script src="/static/js/api.js"></script>
<script>
    new Vue({
        el: '#app',
        data: function(){
            return {
                user: ${(user)!'null'},
                headerNavList: list.headerNavList,
                examineDialog: false,
                typeId: 2,
                readonly: false,
                result: 1,
                checkedList: [],
                desc: '',
                stateList: [],
                examineId: '',
                accountNavList: list.accountNavList,
                leftMenuList: list.menu,
                cashList: [],
                dialogFormVisible: false,
                currentPage: list.currentPage,
                pageSize: list.pageSize,
                totalCount:0,
                checkedTags:"",
                Tags:[],
                search:{
                    applyTimeStart:'',
                    applyTimeEnd:'',
                    status:'',
                    customerName:''
                }
            }
        },
        mounted:function () {
            this.getStatus();
          this.getList();
        },
        methods: {
            handleCurrentPageChange(val) {
                this.currentPage = val;
                this.getList();
            },
            show (id) {
                this.examineId = id;
                this.examineDialog = true
            },
            formatterTime (row, column) {
                if (row.applyTime !== undefined && (row.applyTime + "").length >= 10) {
                    return (row.applyTime + "").substring(0, 10);
                } else {
                    return row.applyTime;
                }
            },
            getStatus () {
                let that = this;
                this.$get("/dictionary/list/MS_BALANCE_FETCH_STATUS", {}, function (res) {
                    if (res.status === 100) {
                        that.stateList = res.returnValue;
                    } else {
                        that.$alert('服务器错误','提示',{
                            confirmButtonText:'确定',
                        })
                    }
                }, function (res) {
                    that.$alert('服务器错误','提示',{
                        confirmButtonText:'确定',
                    })
                })
            },
            saveCallback () {
                let isValid = true;
                let that = this;
                this.result = this.$refs.examineDialog.examineForm.result;
                this.desc = this.$refs.examineDialog.examineForm.desc;
                this.checkedList = this.$refs.examineDialog.checkTag;
                this.$refs.examineDialog.$refs.examineForm.validate(function (valid) {
                    if (!valid) {
                        isValid = false;
                    }
                })
                if (isValid) {
                    let desc = "";
                    if (this.checkedList[0] === 999) {
                        desc = this.desc;
                    } else {
                        desc = this.checkedList.join(",");
                    }
                    let obj = {
                        contentId: this.examineId,
                        contentType: this.typeId,
                        checkResult: this.result,
                        checkDesc: desc
                    }
                    let loading = this.$loading({fullscreen: true, lock: true});
                    this.http("/point/check", obj, function (res) {
                        if (res.status === 200) {
                            that.getList();
                            that.examineDialog = false;
                            loading.close();
                        } else {
                            loading.close();
                            that.$alert('服务器错误', '提示', {
                                confirmButtonText: '确定',
                            });
                        }
                    }, function (res) {
                        loading.close();
                        that.$alert('服务器错误', '提示', {
                            confirmButtonText: '确定',
                        });
                    })
                } else {
                    this.$message.error('请完善信息');
                }
            },
            cancelCallback () {
                this.examineDialog = false;
            },
            exportPoint () {
                window.open("/point/outPut?customerName=" + this.search.customerName + "&applyTimeStart=" + this.formatTime(this.search.applyTimeStart, true)
                        + "&applyTimeEnd=" + this.formatTime(this.search.applyTimeEnd, true) + "&status=" + this.search.status);
            },
            getList(){
                let that = this;
                let obj = {
                   customerName: this.search.customerName,
                   status:this.search.status,
                   applyTimeStart:this.formatTime(this.search.applyTimeStart, true),
                   applyTimeEnd:this.formatTime(this.search.applyTimeEnd, true),
                   currentPage: this.currentPage,
                   pageSize:this.pageSize,
                   isAll:1
                }
                this.http('/point/list',obj,function (res) {
                    if(res.status == 200){
                        that.cashList = res.data.list;
                        that.totalCount = res.data.total;
                    }else{
                        that.$alert('服务器错误','提示',{
                            confirmButtonText:'确定'
                        })
                    }
                },function (res) {
                    that.$alert('服务器错误','提示',{
                        confirmButtonText:'确定'
                    })
                })
            },
            clearSearch(){
                this.search.customerName = ''
                this.search.status = ''
                this.search.applyTimeStart = ''
                this.search.applyTimeEnd = ''
                this.getList()
            }
        }
    })
</script>

<!-- 20170105 --></body>
</html>